<link href="<?php echo URLPRE;?>static/admin/css/admin_full.css" rel="stylesheet" />
<link href="<?php echo URLPRE;?>static/public/Lib/artDialog/skins/default.css" rel="stylesheet" />
<link href="<?php echo URLPRE;?>static/public/Lib/Kalendajs/build/kalendae.css" rel="stylesheet" />
<link href="<?php echo URLPRE;?>static/admin/css/font_icon.css" rel="stylesheet" />
<link href="<?php echo URLPRE;?>static/admin/css/font_icon.css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo URLPRE;?>static/public/js/jquery/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/public/js/jquery/jquery.form.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/validate/jquery.validate.1.9.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/validate/jquery.metadata.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/validate/messages_cn.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/artDialog/jquery.artDialog.source.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/artDialog/plugins/iframeTools.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/admin/js/common.js?newversion"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/Kalendajs/build/kalendae.standalone.js"></script>

<script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/select2/select2.min.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/select2/select2_locale_zh-CN.js"></script>
<link href="<?php echo URLPRE;?>static/public/Lib/select2/select2.css" rel="stylesheet" />
<link href="<?php echo URLPRE;?>static/public/Lib/select2/select2-bootstrap.css" rel="stylesheet" />
<link href="<?php echo URLPRE;?>static/admin/css/font_icon.css" rel="stylesheet" />
<style>.form-group{margin-bottom:0}</style>
<div>
    <div class="h_a">说明</div>
    <div class="prompt_text">
        <ul>
            <li>只有已认证的公众号才能查看自己的粉丝</li>
        </ul>
    </div>
    <div class="nav">
        <ul>
            <li class="current"><a href="<?php echo site_url('weixin/wfans/index');?>">粉丝管理</a></li>
            <li><a href="<?php echo site_url('weixin/wfans/group');?>">分组管理</a></li>
        </ul>
    </div>
    <div class="table_list">
        <form class="formvalidate" action="" method="post">
        <table width="100%">
            <thead>
            <tr>
                <td>批量分组</td>
                <td>昵称</td>
                <td>性别</td>
                <td>地区</td>
                <td>关注时间</td>
                <td>分组</td>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($fansinfo as $v) { ?>
            <tr>
                <td>
                    <input type="checkbox" value="<?php echo $v['openid']?>" class="openids cbr cbr-secondary">
                </td>
                <td>
                    <img style="vertical-align:middle;width:50px" src="<?php echo substr($v['headimgurl'],0,-1).'96'?>" />
                    <span title="<?php echo $v['openid'];?>"><?php echo $v['nickname']?></span>
                </td>
                <td><?php echo $v['sex']==1 ? '男' :($v['sex'] ==2 ? '女':'') ;?></td>
                <td>
                    <?php echo $v['country'],' ', $v['province'], ' ', $v['city']?>
                </td>
                <td>
                    <?php echo $v['subscribe'] ? date('Y-m-d H:i:s', $v['subscribe_time']) : '已取消关注';?>
                </td>
                <td>
                    <select style="width:120px" class="supplier" name="group_id[<?php echo $v['openid']?>]">
                        <?php foreach ($groups as $group) { ?>
                        <option value="<?php echo $group['id'] ?>" <?php echo $group['id'] == $v['groupid'] ? 'selected' : ''?>><?php echo $group['name']?></option>
                        <?php } ?>
                    </select>
                </td>
            </tr>
            <?php }?>
            </tbody>
            <tbody>
                <tr>
                    <td>
                        <select style="width:120px" class="supplier" onchange="return savegroupids(this);">
                            <?php foreach ($groups as $group) { ?>
                                <option value="<?php echo $group['id'] ?>"><?php echo $group['name']?></option>
                            <?php } ?>
                        </select>
                    </td>

                    <td colspan="4">
                        <div class="form-group">
                            <button class="btn1 btn-secondary btn-single" type="submit">保存</button>
                        </div>
                    </td></tr>
            </tbody>
            </table>
        </form>
    </div>
</div>
<div class="page_nav">
    <?php echo $this->mypageclass->show(2); ?>
</div>
<script type="text/javascript">
    $('.supplier').select2({placeholder: "请选择",allowClear: true});

    function savegroupids(obj){
        var openids = [];
        $('.openids:checked').each(function(){
            openids.push($(this).val());
        });
        $.post('<?php site_url('weixin/wfans/index')?>', {openids:openids,groupid:obj.value}, function(msg){
            artDialog.alert(msg.info);
            setTimeout(function(){
                window.location.href =window.location.href;
            }, 1500);
        });
    }
</script>